/*
 * Copyright 2008-2009 Nobject.org, All Rights Reserved.
 * 
 * This software is licensed under LGPL license.
 * See terms of license at gnu.org.
 * 
 * For more information,visit:
 * 
 * http://www.nobject.org
 */
package org.nobject.common.code.model.javascript;


/**
 * Block Model class
 * 
 * @author bianrongjun
 * @version 1.0
 */
public class BlockModel {

	/**
	 * Block Body
	 */
	private StringBuffer blockBody = new StringBuffer("");

	/**
	 * Block comment
	 */
	private String blockComment = null;

	/**
	 * Constructor
	 */
	public BlockModel() {
		this.blockBody=new StringBuffer();
	}

	/**
	 * Constructor
	 * 
	 * @param functionName
	 */
	public BlockModel(String blockBody) {
		this.blockBody=new StringBuffer();
		this.blockBody.append(blockBody);
	}

	/**
	 * Get BlockBody
	 * 
	 * @return
	 */
	public String getBlockBody() {
		return blockBody.toString();
	}

	/**
	 * Set BlockBody
	 * 
	 * @param blockBody
	 */
	public void setBlockBody(String blockBody) {
		this.blockBody = new StringBuffer(blockBody);
	}

	/**
	 * Get BlockComment
	 * 
	 * @return
	 */
	public String getBlockComment() {
		return blockComment;
	}

	/**
	 * Set BlockComment
	 * 
	 * @param blockComment
	 */
	public void setBlockComment(String blockComment) {
		this.blockComment = blockComment;
	}

	/**
	 * append
	 * @param content
	 */
	public void append(String content){
		this.blockBody.append(content).append("\r\n");
	}
	
	/**
	 * Generate Block String
	 * 
	 * @return
	 */
	public String generateBlockString() {
		StringBuffer sb = new StringBuffer();
		if (this.blockComment != null) {
			sb.append("\n/** " + this.blockComment + " */\n");
		}
		sb.append(this.blockBody);
		return sb.toString();
	}
}
